﻿using NetFrame.AbsClass;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetFrame;
using NetFrame.EnDecode;

namespace ServerDemo {
    public class MessageCenter : AbsMessageCenter {
        public override void OnClientClose(BaseToken token, string error) {
        }

        public override void OnClientConnected(BaseToken token) {
            Console.WriteLine(DateTime.Now.Date + "\t客户端登陆\t" + token.socket.RemoteEndPoint);
            token.Send(new TransModel(1,2,3,SeProbuf.Se("hello,i am server")));
        }

        public override void OnMessageReceive(BaseToken token, TransModel model) {
            //处理model，根据type分发消息
            Console.WriteLine(model.getMessage<string>());
        }

        //public override void OnMessageReceive(BaseToken token, string content) {
        //    Console.WriteLine(token.socket.RemoteEndPoint+"\t"+content);
        //}

    }
}
